package com.yydm.servicecount.scheduled;

import com.yydm.servicecount.service.StatisticsDailyService;
import com.yydm.servicecount.utils.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Classname ScheduledTask
 * @Description TODO
 * @Version 1.0.0
 * @Date 2022/7/17 0:42
 * @Created by liu25
 */
@Component
public class ScheduledTask {

    @Autowired
    private StatisticsDailyService statisticsDailyService;

    //    每天凌晨一点执行程序把数据查询进行添加 查询并添加的是前一天的数据
    @Scheduled(cron = "0 0 1 * * ?")
    public void task2() {
        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }

    @Scheduled(cron = "0 0 12 * * ?")
    public void task1() {
        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
    }
//
//    @Scheduled(cron = "0 0/2 * * * ?")
//    public void task3() {
//        statisticsDailyService.registerCount(DateUtil.formatDate(DateUtil.addDays(new Date(), -1)));
//        System.out.println("task3.............");
//    }


}
